package br.com.skytef.servlet.POS;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import br.com.skytef.beans.POS.Logica;
import br.com.skytef.beans.POS.SystemSession;
import br.com.skytef.dao.LocalDao;
import br.com.skytef.entity.LocalEntity;
import br.com.skytef.entity.MessageEntity;
import br.com.skytef.jdbc.ConnectionFactory;

public class ServletTableSelect implements Logica {

	@Override
	public String executa(HttpServletRequest request, HttpServletResponse response, HttpSession session) throws Exception {

		SystemSession sysSessionRecover = null;
		SystemSession sysSessionNew = null;

		try {
			sysSessionRecover = (SystemSession) session.getAttribute("SysSession");
			sysSessionNew = sysSessionRecover;
			
			if (sysSessionNew.getMethodNext().equals("callSend")) {
				sysSessionNew = this.callSend(request, response, session);
			}else if (sysSessionNew.getMethodNext().equals("callReturn")){
				sysSessionNew = this.callReturn(request, response, session);
			}else if (sysSessionNew.getMethodNext().equals("callLoadLocal")){
				sysSessionNew = this.callSelectLocal(request, response, session);
			}

		} catch (Exception e) {
			System.out.println("##> Erro ao processar a servlet: " + sysSessionNew.getNextServlet() + "\n" + e.getMessage());
		}

		session.setAttribute("SysSession", sysSessionNew);
		return sysSessionNew.getNextView();
	}
	
	private SystemSession callSend(HttpServletRequest request, HttpServletResponse response, HttpSession session) throws Exception {
		MessageEntity msg = new MessageEntity();
		SystemSession sysSessionNew = null;

		return sysSessionNew;
	}

	private SystemSession callReturn(HttpServletRequest request, HttpServletResponse response, HttpSession session) throws Exception {
		MessageEntity msg = new MessageEntity();
		SystemSession sysSessionNew = null;

		return sysSessionNew;
	}
	
	private SystemSession callSelectLocal(HttpServletRequest request, HttpServletResponse response, HttpSession session) throws Exception{
		SystemSession sysSessionRecover = (SystemSession) session.getAttribute("SysSession");
		SystemSession sysSessionNew = sysSessionRecover;
		
		
		return sysSessionNew;		
	}
	
}
